package com.leyou.order.web;


import com.leyou.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("pay")
public class PayController {

    @Autowired
    private OrderService orderService;

    /**
     * 微信支付成功回调
     * @param data
     * @return
     */

    @PostMapping(value = "/wx/notify",produces = "application/xml")
    public ResponseEntity<Map<String,String>> wxNotify(@RequestBody Map<String,String> data ){
        orderService.handleNotify(data);
        Map<String,String> msg = new HashMap<>();
        msg.put("return_code","SUCCESS");
        msg.put("return_msg","OK");
        return ResponseEntity.ok(msg);

    }
}
